<route lang="json5" type="page">
{
  style: {
    navigationBarTitleText: '设置',
  },
}
</route>
<template>
  <view class="flex flex-col h-screen bg-gray-100">
    <!-- 退出登录按钮 -->
    <view class="mt-4 px-4">
      <button
        class="w-full py-3 bg-white text-red-500 text-base text-center rounded-md shadow"
        hover-class="bg-gray-100"
        @click="handleLogoutClick"
      >
        退出登录
      </button>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { useUserStore } from '@/store'
import { logoutApi } from '@/service/me/login/authApi'

const userStore = useUserStore()
const handleLogoutClick = async function () {
  if (userStore.isLogined) {
    await logoutApi()
    userStore.clearUserInfo()
  }
  uni.navigateBack()
}
</script>

<style scoped></style>
